package com.rh.manage.factory;

import com.formdev.flatlaf.ui.FlatPopupMenuBorder;
import com.rh.manage.annotation.ComponentBean;
import com.rh.manage.config.ReadUserConfig;
import com.rh.manage.constants.FrameCategoryEnum;
import com.rh.manage.model.UserConfig;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;

import javax.swing.JTextField;
import java.awt.Font;

/**
 * git项目地址 编辑框 工厂
 */
@ComponentBean(FrameCategoryEnum.PRO_MANAGE)
public class GitProjectPathTextFieldFactory {

    @Autowired
    private ReadUserConfig readUserConfig;
    private JTextField textField;

    public @NotNull JTextField init() {
        textField = new JTextField();
        textField.setFont(new Font("Monaco", Font.PLAIN, 19));
        textField.setBorder(new FlatPopupMenuBorder());
        UserConfig userConfig = readUserConfig.getUserConfig();
        if (userConfig != null) {
            textField.setText(userConfig.getGitProjectPath());
        }
        return textField;
    }
}
